package com.yihuier.yihuier.Mapper.UserManager;

import com.yihuier.yihuier.Entity.UserManager.Department;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

//@Component(value="Mapper")
@Mapper
public interface DepartmentMapper {

    @Select("SELECT department_name FROM bz_department WHERE department_id = #{department_id};")
    String selectNameById(@Param("department_id")int department_id );

    @Select("SELECT department_belongs_company  FROM bz_department WHERE department_id = #{department_id};")
    int selectCompanyIdByDepartmentId(@Param("department_id")int department_id);

    @Results({
            @Result(property = "department_id" , column = "department_id"),
            @Result(property = "department_name" , column = "department_name"),
    })
    @Select("SELECT department_id,department_name  FROM bz_department WHERE department_belongs_company = #{company_id} and department_status = 1;")
    ArrayList<Department> selectDepartmentIdsAndDepartmentNamesByCompanyId(@Param("company_id")int company_id);

    @Insert("INSERT into bz_department(department_name,department_belongs_company) VALUES (#{department_name},#{company_id});")
    int insertDepartment(@Param("department_name")String department_name,@Param("company_id")int company_id );

}
